/*
 * controllers_network.h
 *
 *  Created on: Oct 14, 2010
 *      Author: khanton
 */

#ifndef CONTROLLERS_NETWORK_H_
#define CONTROLLERS_NETWORK_H_

#include <boost/unordered_map.hpp>
#include <boost/thread.hpp>

#include "con_state.h"
#include "con_connection.h"
#include "teacup.h"

class controllers_network
{
	public:
	
		void create_controller_connection(con_state::controller_id _id, con_connection_ptr _connection);
		void remove_controller_connection(con_state::controller_id _id);

		bool get_controller_state_by_id(con_state::controller_id _id, con_state &_state);

		void set_connection_command_by_id(con_state::controller_id _id, con_command *_command);
		
		void close_all_connection();
		
	protected:

		typedef boost::weak_ptr<con_connection> connection_week_ptr;

		typedef boost::unordered_map<con_state::controller_id, connection_week_ptr> skynet_t;

		boost::mutex mutex_;

		skynet_t skynet_;
};

#endif /* CONTROLLERS_NETWORK_H_ */
